package kpi.java_training.domain.teaching;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Alex Kebkalo (kebka@mail.ru) on 20.11.13.
 */
public class AnswersList {
    private List<String> answers;
    private int currentAnswer;

    public AnswersList() {
        answers = new ArrayList<>();
        currentAnswer = 0;
    }

    public List<String> getAnswers() {
        return answers;
    }

    public AnswersList(List<String> answers) {
        this.answers = answers;
        currentAnswer = 0;
    }

    public void add(String answer) {
        answers.add(answer);
        currentAnswer++;
    }

    public String getNextAnswer() {
        currentAnswer++;
        if (currentAnswer > answers.size()) {
            return "";
        }
        return answers.get(currentAnswer -1);
    }

    public void removeLastAnswer() {
        if (answers.size() > 0) {
            answers.remove(answers.size()-1);
            if (currentAnswer > 0) {
                currentAnswer--;
            }
        }
    }

    public void resetAnswersCounter() {
        currentAnswer = 0;
    }

    public boolean isEmpty() {
        return answers.isEmpty();
    }

    public int size() {
        return answers.size();
    }
}
